import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:moose_app/core/utils/logger.dart';
import 'package:moose_app/ui/routers/application.dart';
import 'package:moose_app/ui/screens/splash/splash_screen.dart';
import 'package:moose_app/ui/values/values.dart';

import 'ui/routers/routers.dart';

class ATHApp extends StatelessWidget {
  ATHApp({Key key}) : super(key: key) {
    final router = FluroRouter();
    ATHRoutes.configureRoutes(router);
    ATHApplication.router = router;
    _initEasyLoading();
    ATHLogger.init();
  }

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
        designSize: Size(750, 1334),
        allowFontScaling: false,
        builder: () => buildApp(context));
  }

  Widget buildApp(BuildContext context) {
    return MaterialApp(
      title: 'Moose Flutter Learn',
      theme: Theme.of(context).copyWith(
          appBarTheme: Theme.of(context).appBarTheme.copyWith(
                color: kColorPrimary,
                elevation: 0,
                brightness: Brightness.dark,
              )),
      debugShowCheckedModeBanner: false,
      home: ATHSplashScreen(),
      onGenerateRoute: ATHApplication.router.generator,
      builder: EasyLoading.init(),
    );
  }

  _initEasyLoading() {
    EasyLoading.instance
      ..displayDuration = const Duration(milliseconds: 2000)
      ..indicatorType = EasyLoadingIndicatorType.rotatingCircle
      ..loadingStyle = EasyLoadingStyle.dark
      ..fontSize = 16.0
      ..indicatorSize = 32.0
      ..radius = 10.0
      ..progressColor = Colors.yellow
      ..backgroundColor = Colors.green
      ..indicatorColor = Colors.yellow
      ..textColor = Colors.yellow
      ..maskColor = Colors.blue.withOpacity(0.5)
      ..userInteractions = true
      ..dismissOnTap = false;
  }
}
